package com.digital.smartgrow.service.title;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.digital.smartgrow.dao.title.PunishmentsMapper;
import com.digital.smartgrow.dto.title.Punishment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
public class PunishmentsServiceImpl implements PunishmentService{


    @Autowired
    PunishmentsMapper punishmentsMapper;

    @Override
    @Transactional
    public List<Punishment> findList(Punishment punishment) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("idcard", punishment.getIdcard());
        queryWrapper.eq("status", 0);
        return punishmentsMapper.selectList(queryWrapper);
    }

    @Override
    @Transactional
    public void deleteCommend(Punishment punishment) {
        Punishment punishment1 = new Punishment();
        Date date = new Date();
        punishment1.setStatus(1).setId(punishment.getId()).setTime(date);
        punishmentsMapper.updateById(punishment1);
    }
}
